$(function(){
	var setLangBtn = $('#setLang');
	var menu = $('#setLang .menu');
	var menus = $('#setLang .menu span');
	
	var changeBtnBg = function(color){
		setLangBtn.css({
			'background': color
		});
	};
	var hideMenu = function(){
		menu.hide();
		changeBtnBg('none');
	};
	var showMenu = function(){
		menu.slideDown();
		changeBtnBg('#808b93');
	};
	menu.hover(function(){}, function(){
		hideMenu();
	});
	setLangBtn.click(function(){
		showMenu();
	});
	
	menus.each(function(){
		$(this).click(function(){			
			$.post('/main/setLang',
				{
					'lang': $(this).attr('id')
				}, function(response){
				//alert(response);
				eval('var response = '+response);
				if (response.result) {
					location.reload();
				} else
					alert(response.error);
			});
		});
	});
});